package servlet.recipe.page;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import mysql.JdbcUtil;

import java.io.IOException;

public class Delete extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        int style = Integer.parseInt(req.getParameter("style"));
        JdbcUtil jdbc = new JdbcUtil();
        if (jdbc.checkNotNull(id)) {
            if(style==1) {
                String sql = "delete from recipe where id="+id;
            }else if(style==2) {
                String sql = "delete from accounts where account_id="+id;
            }
        }
        req.getRequestDispatcher("chishi/jsp/admin.jsp").forward(req, resp);


    }
}
